﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Excel;

namespace ObjectModel.Excel.Old
{
    /// <summary>
    /// A dictionary of WorksheetEvents objects that adds to items to itself on demand.
    /// </summary>
    public class WorksheetEventsDictionary : Dictionary<Worksheet, WorksheetEvents>
    {
        public new WorksheetEvents this[Worksheet ws]
        {
            get
            {
                try { return base[ws]; }
                catch (KeyNotFoundException)
                {
                    base.Add(ws, new WorksheetEvents(ws));
                    return base[ws];
                }
            }
            set { base[ws] = value; }
        }
    }
}
